home *** CD-ROM | disk | FTP | other *** search
- # test regular expressions
- # usage : regexp (regex, text_to_match)
- # returns 1 in case of a match
- # 0 otherwise
- string regex
- string text_to_match
-
- # will match Solaris ftp servers with this versions:
- # 2.6, 2.7, 2.8 and 5.6, 5.7, 5.8
- regex = "FTP server \(SunOS (2|5)\.[678]\) ready"
-
- text_to_match = "220 mars FTP server (SunOS 5.7) ready."
- if regexp(regex, text_to_match) = 1
- echo(text_to_match + " matched")
- else
- echo(text_to_match + " not matched !")
- end if
-
- text_to_match = "220 mars FTP server (SunOS 5.5) ready."
- if regexp(regex, text_to_match) = 1
- echo(text_to_match + " matched")
- else
- echo(text_to_match + " not matched !!!")
- end if
-